#include "cpu/exec/helper.h"

make_helper(ret) {
    uint32_t return_addr = swaddr_read(cpu.esp, 4);
    cpu.esp += 4;
    eip = return_addr;

    print_asm("ret");
    return 1;
}

make_helper(ret_imm_v) {
    uint16_t imm16 = instr_fetch(eip + 1, 2);
    uint32_t return_addr = swaddr_read(cpu.esp, 4);
    cpu.esp += 4;
    eip = return_addr;

    cpu.esp += imm16;
    print_asm("ret $0x%x", imm16);
    return 3;
}